import { createStore } from 'vuex'

export default createStore({
  state: {
    token:localStorage.getItem('token'),
    localPhoneNumber:'15280159663',  // 本机号码
    username:localStorage.getItem('username'),
    userId:localStorage.getItem('userId'),
    user:{},
    category:[
      {
        id:1,
        name:'美食',
        subcategory:[
          {name:'全部',imgSrc:''},
          {name:'简餐便当',imgSrc:''},
          {name:'汉堡西餐',imgSrc:''},
          {name:'粥粉面点',imgSrc:''},
          {name:'地方菜系',imgSrc:''},
          {name:'炸卤小吃',imgSrc:''},
          {name:'日韩料理',imgSrc:''},
          {name:'火锅烫捞',imgSrc:''},
          {name:'龙虾烧烤',imgSrc:''},
          {name:'1人吃好',imgSrc:''},
          {name:'招牌菜',imgSrc:''},
        ]
      },
      {
        id:2,
        name:'甜品饮品',
        subcategory:[
          {name:'全部',imgSrc:''},
          {name:'奶茶果汁',imgSrc:''},
          {name:'提神咖啡',imgSrc:''},
          {name:'蛋糕面包',imgSrc:''},
          {name:'甜品',imgSrc:''},
          {name:'中西糕点',imgSrc:''},
          {name:'冰淇淋',imgSrc:''},
          {name:'水果捞',imgSrc:''},
        ]
      },
      {
        id:3,
        name:'商店超市',
        subcategory:[
          {name:'全部',imgSrc:''},
          {name:'大型超市',imgSrc:''},
          {name:'便利店',imgSrc:''},
          {name:'休闲零食',imgSrc:''},
          {name:'乳饮酒水',imgSrc:''},
          {name:'美妆个护',imgSrc:''},
          {name:'母婴百货',imgSrc:''},
          {name:'宠物用品',imgSrc:''},
        ]
      },
      {
        id:4,
        name:'水果鲜花',
        subcategory:[
          {name:'全部',imgSrc:''},
          {name:'水果',imgSrc:''},
          {name:'鲜花绿植',imgSrc:''},
        ]
      },
      {
        id:5,
        name:'买药',
        subcategory:[
          {name:'全部',imgSrc:''},
          {name:'小儿用药',imgSrc:''},
          {name:'妇科用药',imgSrc:''},
          {name:'皮肤用药',imgSrc:''},
          {name:'五官用药',imgSrc:''},
          {name:'呼吸用药',imgSrc:''},
          {name:'肠胃用药',imgSrc:''},
        ]
      },
      {
        id:6,
        name:'买菜',
        subcategory:[
          {name:'全部',imgSrc:''},
          {name:'时令果蔬',imgSrc:''},
          {name:'肉禽蛋',imgSrc:''},
          {name:'海鲜水产',imgSrc:''},
          {name:'冷冻冷藏',imgSrc:''},
          {name:'粮油调味',imgSrc:''},
        ]
      },
      {
        id:7,
        name:'省钱好玩',
        subcategory:[
          {name:'时令官',imgSrc:''},
          {name:'省钱好券',imgSrc:''},
          {name:'天天1块9',imgSrc:''},
        ]
      },
      {
        id:8,
        name:'生活服务',
        subcategory:[
          {name:'跑腿',imgSrc:''},
          {name:'家政洗衣',imgSrc:''},
          {name:'美食团购',imgSrc:''},
          {name:'休闲娱乐',imgSrc:''},
          {name:'丽人医美',imgSrc:''},
          {name:'医疗口腔',imgSrc:''},
          {name:'火车机票',imgSrc:''},
          {name:'酒店',imgSrc:''},
          {name:'景点门票',imgSrc:''},
        ]
      },
      {
        id:9,
        name:'家常菜',
        subcategory:[
          {name:'中式简餐',imgSrc:''},
          {name:'口味川湘',imgSrc:''},
          {name:'江浙菜系',imgSrc:''},
          {name:'北方佳肴',imgSrc:''},
          {name:'西北美食',imgSrc:''},
          {name:'港粤茶餐厅',imgSrc:''},
          {name:'日韩料理',imgSrc:''},
          {name:'私房特色菜',imgSrc:''},
          {name:'火锅香锅',imgSrc:''},
        ]
      },
      {
        id:10,
        name:'粥粉面点',
        subcategory:[
          {name:'米粉米线',imgSrc:''},
          {name:'美味面馆',imgSrc:''},
          {name:'养胃粥品',imgSrc:''},
          {name:'饺子馄饨',imgSrc:''},
          {name:'包子馅饼',imgSrc:''},
          {name:'凉皮肉夹馍',imgSrc:''},
        ]
      },
      {
        id:11,
        name:'汉堡西餐',
        subcategory:[
          {name:'精选',imgSrc:''},
          {name:'汉堡薯条',imgSrc:''},
          {name:'披萨意面',imgSrc:''},
          {name:'轻食沙拉',imgSrc:''},
          {name:'牛排',imgSrc:''},
          {name:'西餐',imgSrc:''},
        ]
      },
      {
        id:12,
        name:'炸卤小吃',
        subcategory:[
          {name:'炸鸡炸串',imgSrc:''},
          {name:'卤味熟食',imgSrc:''},
          {name:'特色小吃',imgSrc:''},
        ]
      },
      {
        id:13,
        name:'龙虾烧烤',
        subcategory:[
          {name:'烧烤',imgSrc:''},
          {name:'小龙虾',imgSrc:''},
          {name:'火锅烤鱼',imgSrc:''},
        ]
      },
      {
        id:14,
        name:'透明餐厅',
        subcategory:[]
      },
    ]
  },
  getters: {
    // 加密的用户名
    encryptedPhone(state){
      return state.username.slice(0,3)+'****'+state.username.slice(7,11);
    },
    // 是否登录
    isLogin:(state)=>{
      return state.token && state.token.length>0 ? true : false
    },
    getToken(state){
      return JSON.parse(state.token)
    }
  },
  mutations: {
    SET_TOKEN:(state,token)=>{
      state.token = token;
    },
    SET_USERNAME:(state,name)=>{
      state.username = name;
    },
    SET_ID:(state,id)=>{
      state.userId = id;
    },
    SET_USER:(state,obj)=>{
      state.user = obj;
    }
  },
  actions: {
  },
  modules: {
  }
})
